<template>
  <div class="tab-control">
    <div v-for="(item, index) in tabControlItem" 
    :key="item"
    class="tab-control-item"
    :class="{active: currentIndex === index}"
    @click="itemBtn(index, item)"> 
      <span>{{item}}</span>
    </div>  
  </div>
</template>

<script>
export default {
  name: 'TabControl',
  data() {
    return {
      currentIndex: 0,
      nowPage: ''
    }
  },
  props: {
    tabControlItem: {
      type: Array,
      Default() {
        return [];
      }
    }
  },
  methods: {
    itemBtn(index, item) {    
      this.currentIndex = index;
      this.$emit('tabControlClick', index, this.tabControlItem[index]);
      
      
    }
  }
}
</script>

<style scoped>
  .tab-control{
    display: flex;
    text-align: center;
    background-color: #fff;
    font-size: 14px;
    height: 44px;
    line-height: 44px;
  }
  .tab-control-item{
    flex: 1;
  }
  .tab-control-item span{
    padding: 6px;
  }

  /* 选中样式 */
  .tab-control .active{
    color: var(--color-high-text);
  }
  .tab-control .active span{
    border-bottom: 2px solid var(--color-tint);
  }
</style>